'use client'

import { useEffect } from "react";

import ChatContainer from "@/components/ai/chat/chat-container"

import { useAppContextSelector } from "@/context/app-context";

const ChatPage = ({ params }: { params: { appId: string } }) => {
    const [apps, setCurrentApp] = useAppContextSelector(state => [state.apps, state.setCurrentApp])

    useEffect(() => {
        const targetApp = apps.find(app => app.id === params.appId)
        setCurrentApp(targetApp ?? null)
    }, [params, apps, setCurrentApp])

    return (
        <main className="flex h-full items-center justify-center p-4">
            <ChatContainer navCollapsedSize={8} />
        </main>
    )
}

export default ChatPage